<?php

namespace app\common\model\users;

use app\common\model\BaseModel;

class Distributor extends BaseModel
{
    protected $table = 'distributor';
    protected $pk = 'id';

    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'create_time';
    protected $updateTime = false;

    protected $type = [
        'create_time' => 'timestamp',
    ];
    
    /**
     * 字段验证规则
     * @var array
     */
    protected $schema = [
        'id'            => 'int',
        'name'          => 'string',
        'contact_person' => 'string',
        'contact_phone' => 'string',
        'address'       => 'string',
        'status'        => 'int',
        'create_time'   => 'timestamp',
    ];

    /**
     * 获取分销商信息
     * @param int $id 分销商ID
     * @return array|null
     */
    public function getInfo(int $id): ?array
    {
        return $this->where('id', $id)->find()?->toArray();
    }
}